package com.liaoban.app.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.liaoban.app.R;
import com.liaoban.app.api.type.Band;
import com.liaoban.app.helper.ImageHelper;
import com.liaoban.app.util.CommonUtils;

import java.util.List;

/**
 * 魅力榜
 */
public class CharmAdapter extends BaseQuickAdapter<Band, BaseViewHolder> {

    public CharmAdapter(@Nullable List<Band> data) {
        super(R.layout.item_charm, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Band item) {
        TextView tvCharm = helper.getView(R.id.tv_charm);
        switch (helper.getLayoutPosition()) {
            case 0:
                tvCharm.setVisibility(View.VISIBLE);
                tvCharm.setText("1");
                tvCharm.setBackgroundResource(R.mipmap.ic_charm1);
                break;
            case 1:
                tvCharm.setVisibility(View.VISIBLE);
                tvCharm.setText("2");
                tvCharm.setBackgroundResource(R.mipmap.ic_charm2);
                break;
            case 2:
                tvCharm.setVisibility(View.VISIBLE);
                tvCharm.setText("3");
                tvCharm.setBackgroundResource(R.mipmap.ic_charm3);
                break;
            default:
                tvCharm.setVisibility(View.GONE);
                break;
        }
        ImageView ivIcon = helper.getView(R.id.iv_icon);
        ImageHelper.load(ivIcon, CommonUtils.getFullPic(item.getWuserSrc()));
        switch (item.getLineStatus()) {
            case 1:
                helper.setBackgroundRes(R.id.tv_line_status, R.drawable.shape_yellow_oval);
                break;
            case 2:
                helper.setBackgroundRes(R.id.tv_line_status, R.drawable.shape_gray_oval);
                break;
            case 3:
                helper.setBackgroundRes(R.id.tv_line_status, R.drawable.shape_red_oval);
                break;
        }
    }
}
